package com.cskaoyan.service;

import com.cskaoyan.bean.Feedback;
import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.FeedbackMapper;
import com.cskaoyan.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class FeedbackServiceImpl implements FeedbackService {
    @Autowired
    FeedbackMapper feedbackMapper;
    @Autowired
    UserMapper userMapper;
    @Override
    public void submitFeedback(Feedback feedback) {
        //todo  这个地方要取出username 查 id
//        feedback.setUserId(1)
//        feedback.setUsername("test1");
        User user = userMapper.selectByPrimaryKey(feedback.getUserId());
        feedback.setUsername(user.getUsername());
        feedback.setAddTime(new Date());
        feedback.setUpdateTime(new Date());
        feedback.setStatus(1);
        feedback.setDeleted(false);
        feedbackMapper.insert(feedback);
    }
}
